﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="PersonalTradingResult.ascx.cs"
    Inherits="TCKQKL.FrontEnd.Web.Controls.PersonalTradingResult" %>
<%@ Import Namespace="TCKQKL.FrontEnd.DataModel" %>
<%@ Import Namespace="TCKQKL.FrontEnd.Config" %>
<link href="../styles/data.css" rel="stylesheet" type="text/css" />


<% if (personal.MainTradingResult != null)
   {%>
<table class="result" style="border: none;">
    <% if (personal.MainTradingResult.TradingResults != null)
           if (personal.MainTradingResult.TradingResults.Count > 0)
           {%>
    <!-- Main orders header -->
    <tr>
        <td class="OrderAlertMessageStyle" colspan="9">
            <img alt="KẾT QUẢ GIAO DỊCH" src="./Images/transactions.gif" 
    style="width: 51px; height: 34px" /><%=personal.MainTradingResult.InvestorProfile.name + " (" + personal.MainTradingResult.InvestorProfile.accountNo + ")"%>
        </td>
    </tr>
    <tr>
        <th class="InnerHeading">
            Mã
        </th>
        <th class="InnerHeading">
            Loại
        </th>
        <th class="InnerHeading">
            Kiểu</th>
        <th class="InnerHeading">
            Lớp
        </th>
        <th class="InnerHeading">
            Trạng thái</th>
        <th class="InnerHeading">
            Ngày</th>
        <th class="InnerHeading">
            Mã CK</th>
        <th class="InnerHeading">
            KL</th>
        <th class="InnerHeading">
            Giá</th>
    </tr>
    <%for (int i = 0; i < personal.MainTradingResult.TradingResults.Count; i++)
      { %>
    <!-- Main orders detail -->
    <tr class="Master">
        <td>
            <%=personal.MainTradingResult.TradingResults[i].RootOrder.orderID%>
        </td>
        <td>
            <%=personal.MainTradingResult.TradingResults[i].RootOrder.OrderSide%>
        </td>
        <td>
            <%=personal.MainTradingResult.TradingResults[i].RootOrder.orderType%>
        </td>
        <td>
            <%=personal.MainTradingResult.TradingResults[i].RootOrder.OrderClass%>
        </td>
        <td>
            <%=personal.MainTradingResult.TradingResults[i].RootOrder.orderStatus%>
        </td>
        <td>
            <%=personal.MainTradingResult.TradingResults[i].RootOrder.openDate.ToString("dd/MM/yyyy")%>
        </td>
        <td>
            <%=personal.MainTradingResult.TradingResults[i].RootOrder.symbol%>
        </td>
        <td style="text-align: right">
            <%=String.Format("{0:0,0}", personal.MainTradingResult.TradingResults[i].RootOrder.quantity)%>
        </td>
        <td style="text-align: right">
            <%=String.Format("{0:0,0}", personal.MainTradingResult.TradingResults[i].RootOrder.price)%>
        </td>
    </tr>
    <%if (personal.MainTradingResult.TradingResults[i].RelatedOrders != null)
          if (personal.MainTradingResult.TradingResults[i].RelatedOrders.Count > 0)
          {%>
    <tr class="even">
        <td colspan="9">
            <table class="trace">
                <!-- Result header -->
                <tr>
                    <td colspan="9">
                        Lệnh liên quan</td>
                </tr>
                <tr>
                    <th class="InnerHeading">
                        Mã
                    </th>
                    <th class="InnerHeading">
                        Loại
                    </th>
                    <th class="InnerHeading">
                        Kiểu</th>
                    <th class="InnerHeading">
                        Lớp
                    </th>
                    <th class="InnerHeading">
                        Trạng thái</th>
                    <th class="InnerHeading">
                        Ngày</th>
                    <th class="InnerHeading">
                        Mã CK</th>
                    <th class="InnerHeading">
                        KL
                    </th>
                    <th class="InnerHeading">
                        Giá</th>
                </tr>
                <!-- Result details-->
                <%for (int k = 0; k < personal.MainTradingResult.TradingResults[i].RelatedOrders.Count; k++)
                  { %>
                <tr>
                    <td class="InnerData">
                        <%=personal.MainTradingResult.TradingResults[i].RelatedOrders[k].orderID%>
                    </td>
                    <td class="InnerData">
                        <%=personal.MainTradingResult.TradingResults[i].RelatedOrders[k].OrderSide%>
                    </td>
                    <td class="InnerData">
                        <%=personal.MainTradingResult.TradingResults[i].RelatedOrders[k].orderType%>
                    </td>
                    <td class="InnerData">
                        <%=personal.MainTradingResult.TradingResults[i].RelatedOrders[k].OrderClass%>
                    </td>
                    <td class="InnerData" style="text-align: right">
                        <%=personal.MainTradingResult.TradingResults[i].RelatedOrders[k].orderStatus%>
                    </td>
                    <td class="InnerData" style="text-align: right">
                        <%=personal.MainTradingResult.TradingResults[i].RelatedOrders[k].openDate.ToString("dd/MM/yyyy")%>
                    </td>
                    <td class="InnerData" style="text-align: right">
                        <%=personal.MainTradingResult.TradingResults[i].RelatedOrders[k].symbol%>
                    </td>
                    <td class="InnerData" style="text-align: right">
                        <%=String.Format("{0:0,0}", personal.MainTradingResult.TradingResults[i].RelatedOrders[k].quantity)%>
                    </td>
                    <td class="InnerData" style="text-align: right">
                        <%=String.Format("{0:0,0}", personal.MainTradingResult.TradingResults[i].RelatedOrders[k].price)%>
                    </td>
                </tr>
                <%}%>
            </table>
        </td>
    </tr>
    <%}%>
    <%if (personal.MainTradingResult.TradingResults[i].DetailMatched != null)
          if (personal.MainTradingResult.TradingResults[i].DetailMatched.Count > 0)
          {%>
    <tr class="even">
        <td colspan="9">
            <table class="trace">
                <!-- Result header -->
                <tr>
                    <td colspan="8">
                        Chi tiết giao dịch</td>
                </tr>
                <tr>
                    <th class="InnerHeading">
                        Mã&nbsp;
                    </th>
                    <th class="InnerHeading">
                        Ngày</th>
                    <th class="InnerHeading">
                        Loại
                    </th>
                    <th class="InnerHeading">
                        Mã CK</th>
                    <th class="InnerHeading">
                        KL
                    </th>
                    <th class="InnerHeading">
                        Giá</th>
                    <th class="InnerHeading">
                        Phí
                    </th>
                    <th class="InnerHeading">
                        Mã xác nhận
                    </th>
                </tr>
                <!-- Result details-->
                <%for (int j = 0; j < personal.MainTradingResult.TradingResults[i].DetailMatched.Count; j++)
                  { %>
                <tr>
                    <td class="InnerData">
                        <%=personal.MainTradingResult.TradingResults[i].DetailMatched[j].orderID%>
                    </td>
                    <td class="InnerData">
                        <%=personal.MainTradingResult.TradingResults[i].DetailMatched[j].transDate.ToString("dd/MM/yyyy")%>
                    </td>
                    <td class="InnerData">
                        <%=personal.MainTradingResult.TradingResults[i].DetailMatched[j].TransType%>
                    </td>
                    <td class="InnerData">
                        <%=personal.MainTradingResult.TradingResults[i].DetailMatched[j].stockCode%>
                    </td>
                    <td class="InnerData" style="text-align: right">
                        <%=String.Format("{0:0,0}", personal.MainTradingResult.TradingResults[i].DetailMatched[j].stockQtty)%>
                    </td>
                    <td class="InnerData" style="text-align: right">
                        <%=String.Format("{0:0,0}", personal.MainTradingResult.TradingResults[i].DetailMatched[j].price)%>
                    </td>
                    <td class="InnerData" style="text-align: right">
                        <%=String.Format("{0:0,0}", personal.MainTradingResult.TradingResults[i].DetailMatched[j].feeAmount)%>
                    </td>
                    <td class="InnerData" style="text-align: right">
                        <%=personal.MainTradingResult.TradingResults[i].DetailMatched[j].confirmNo%>
                    </td>
                </tr>
                <%}%>
                <tr class="subtotal">
                    <td class="InnerData" colspan="2">
                        Khớp lệnh</td>
                    <td class="InnerData">
                        <%=personal.MainTradingResult.TradingResults[i].Side%>
                    </td>
                    <td class="InnerData">
                        <%=personal.MainTradingResult.TradingResults[i].Symbol%>
                    </td>
                    <td class="InnerData">
                        <%=String.Format("{0:0,0}", personal.MainTradingResult.TradingResults[i].SubQtty)%>
                    </td>
                    <td class="InnerData">
                        <%=(personal.MainTradingResult.TradingResults[i].SubQtty != 0) ? String.Format("{0:0,0}", (personal.MainTradingResult.TradingResults[i].SubValue / personal.MainTradingResult.TradingResults[i].SubQtty)) : String.Empty%>
                    </td>
                    <td class="InnerData">
                        <%=String.Format("{0:0,0}", personal.MainTradingResult.TradingResults[i].FeeAmount)%>
                    </td>
                    <td class="InnerData">
                        &nbsp;
                    </td>
                    <td class="InnerData">
                        <%=String.Format("{0:0,0}", personal.MainTradingResult.TradingResults[i].SubValue)%>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
    <%}%>
    <%}%>
    <%}%>
</table>
<%} %>
<% if (personal.AssignTradingResult != null)
       if (personal.AssignTradingResult.Count > 0)
           foreach (TotalTradingResultUI assign in personal.AssignTradingResult)
           {%>
<% if (assign.TradingResults != null)
       if (assign.TradingResults.Count > 0)
       {%>
<br />
<table class="result" style="border: none;">
    <!-- Main orders header -->
    <tr>
        <td class="Master" colspan="9">
            <img alt="KẾT QUẢ GIAO DỊCH" src="./Images/transactions.gif" 
    style="width: 51px; height: 34px" /><%=assign.InvestorProfile.name + " (" + assign.InvestorProfile.accountNo + ")" %>
        </td>
    </tr>
    <tr>
        <th class="InnerHeading">
            Mã
        </th>
        <th class="InnerHeading">
            Loại
        </th>
        <th class="InnerHeading">
            Kiểu</th>
        <th class="InnerHeading">
            Lớp
        </th>
        <th class="InnerHeading">
            Trạng thái</th>
        <th class="InnerHeading">
            Ngày</th>
        <th class="InnerHeading">
            Mã CK</th>
        <th class="InnerHeading">
            KL</th>
        <th class="InnerHeading">
            Giá</th>
    </tr>
    <%for (int i = 0; i < assign.TradingResults.Count; i++)
      { %>
    <!-- Main orders detail -->
    <tr class="Master">
        <td>
            <%=assign.TradingResults[i].RootOrder.orderID%>
        </td>
        <td>
            <%=assign.TradingResults[i].RootOrder.OrderSide%>
        </td>
        <td>
            <%=assign.TradingResults[i].RootOrder.orderType%>
        </td>
        <td>
            <%=assign.TradingResults[i].RootOrder.OrderClass%>
        </td>
        <td>
            <%=assign.TradingResults[i].RootOrder.orderStatus%>
        </td>
        <td>
            <%=assign.TradingResults[i].RootOrder.openDate.ToString("dd/MM/yyyy")%>
        </td>
        <td>
            <%=assign.TradingResults[i].RootOrder.symbol%>
        </td>
        <td style="text-align: right">
            <%=String.Format("{0:0,0}", assign.TradingResults[i].RootOrder.quantity)%>
        </td>
        <td style="text-align: right">
            <%=String.Format("{0:0,0}", assign.TradingResults[i].RootOrder.price)%>
        </td>
    </tr>
    <%if (assign.TradingResults[i].RelatedOrders != null)
          if (assign.TradingResults[i].RelatedOrders.Count > 0)
          {%>
    <tr class="even">
        <td colspan="9">
            <table class="trace">
                <!-- Result header -->
                <tr>
                    <td colspan="9">
                        Lệnh liên quan</td>
                </tr>
                <tr>
                    <th class="InnerHeading">
                        Mã
                    </th>
                    <th class="InnerHeading">
                        Loại
                    </th>
                    <th class="InnerHeading">
                        Kiểu</th>
                    <th class="InnerHeading">
                        Lớp
                    </th>
                    <th class="InnerHeading">
                        Trạng thái</th>
                    <th class="InnerHeading">
                        Ngày</th>
                    <th class="InnerHeading">
                        Mã CK</th>
                    <th class="InnerHeading">
                        KL
                    </th>
                    <th class="InnerHeading">
                        Giá</th>
                </tr>
                <!-- Result details-->
                <%for (int k = 0; k < assign.TradingResults[i].RelatedOrders.Count; k++)
                  { %>
                <tr>
                    <td class="InnerData">
                        <%=assign.TradingResults[i].RelatedOrders[k].orderID%>
                    </td>
                    <td class="InnerData">
                        <%=assign.TradingResults[i].RelatedOrders[k].OrderSide%>
                    </td>
                    <td class="InnerData">
                        <%=assign.TradingResults[i].RelatedOrders[k].orderType%>
                    </td>
                    <td class="InnerData">
                        <%=assign.TradingResults[i].RelatedOrders[k].OrderClass%>
                    </td>
                    <td class="InnerData" style="text-align: right">
                        <%=assign.TradingResults[i].RelatedOrders[k].orderStatus%>
                    </td>
                    <td class="InnerData" style="text-align: right">
                        <%=assign.TradingResults[i].RelatedOrders[k].openDate.ToString("dd/MM/yyyy")%>
                    </td>
                    <td class="InnerData" style="text-align: right">
                        <%=assign.TradingResults[i].RelatedOrders[k].symbol%>
                    </td>
                    <td class="InnerData" style="text-align: right">
                        <%=String.Format("{0:0,0}", assign.TradingResults[i].RelatedOrders[k].quantity)%>
                    </td>
                    <td class="InnerData" style="text-align: right">
                        <%=String.Format("{0:0,0}", assign.TradingResults[i].RelatedOrders[k].price)%>
                    </td>
                </tr>
                <%}%>
            </table>
        </td>
    </tr>
    <%}%>
    <%if (assign.TradingResults[i].DetailMatched != null)
          if (assign.TradingResults[i].DetailMatched.Count > 0)
          {%>
    <tr class="even">
        <td colspan="9">
            <table class="trace">
                <!-- Result header -->
                <tr>
                    <td colspan="8">
                        Chi tiết giao dịch</td>
                </tr>
                <tr>
                    <th class="InnerHeading">
                        Mã&nbsp;
                    </th>
                    <th class="InnerHeading">
                        Ngày</th>
                    <th class="InnerHeading">
                        Loại
                    </th>
                    <th class="InnerHeading">
                        Mã CK</th>
                    <th class="InnerHeading">
                        KL
                    </th>
                    <th class="InnerHeading">
                        Giá</th>
                    <th class="InnerHeading">
                        Phí
                    </th>
                    <th class="InnerHeading">
                        Mã xác nhận
                    </th>
                </tr>
                <!-- Result details-->
                <%for (int j = 0; j < assign.TradingResults[i].DetailMatched.Count; j++)
                  { %>
                <tr>
                    <td class="InnerData">
                        <%=assign.TradingResults[i].DetailMatched[j].orderID%>
                    </td>
                    <td class="InnerData">
                        <%=assign.TradingResults[i].DetailMatched[j].transDate.ToString("dd/MM/yyyy")%>
                    </td>
                    <td class="InnerData">
                        <%=assign.TradingResults[i].DetailMatched[j].TransType%>
                    </td>
                    <td class="InnerData">
                        <%=assign.TradingResults[i].DetailMatched[j].stockCode%>
                    </td>
                    <td class="InnerData" style="text-align: right">
                        <%=String.Format("{0:0,0}", assign.TradingResults[i].DetailMatched[j].stockQtty)%>
                    </td>
                    <td class="InnerData" style="text-align: right">
                        <%=String.Format("{0:0,0}", assign.TradingResults[i].DetailMatched[j].price)%>
                    </td>
                    <td class="InnerData" style="text-align: right">
                        <%=String.Format("{0:0,0}", assign.TradingResults[i].DetailMatched[j].feeAmount)%>
                    </td>
                    <td class="InnerData" style="text-align: right">
                        <%=assign.TradingResults[i].DetailMatched[j].confirmNo%>
                    </td>
                </tr>
                <%}%>
                <tr class="subtotal">
                    <td class="InnerData" colspan="2">
                        Subtotal
                    </td>
                    <td class="InnerData">
                        <%=assign.TradingResults[i].Side%>
                    </td>
                    <td class="InnerData">
                        <%=assign.TradingResults[i].Symbol%>
                    </td>
                    <td class="InnerData">
                        <%=String.Format("{0:0,0}", assign.TradingResults[i].SubQtty)%>
                    </td>
                    <td class="InnerData">
                        <%=(assign.TradingResults[i].SubQtty != 0) ? String.Format("{0:0,0}", (assign.TradingResults[i].SubValue / assign.TradingResults[i].SubQtty)) : String.Empty%>
                    </td>
                    <td class="InnerData">
                        <%=String.Format("{0:0,0}", assign.TradingResults[i].FeeAmount)%>
                    </td>
                    <td class="InnerData">
                        &nbsp;
                    </td>
                    <td class="InnerData">
                        <%=String.Format("{0:0,0}", assign.TradingResults[i].SubValue)%>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
    <%}%>
    <%}%>
</table>
<br />
<%}%>
<%} %>